Change multiple files and folders permissions

To change all the directories to 755 (drwxr-xr-x):

find /var/www/htdocs -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r--r--):

find /html/www/htdocs -type f -exec chmod 644 {} \;
  • chmod 755 {} specifies the command that will be executed by find for each directory
  • chmod 644 {} specifies the command that will be executed by find for each file
  • {} is replaced by the path
  • ; the semicolon tells find that this is the end of the command it's supposed to execute
  • \; the semicolon is escaped, otherwise it would be interpreted by the shell instead of find

Search Results